package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysOutlet;
import com.ruoyi.system.service.ISysOutletService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 网点信息管理Controller
 * 
 * @author ruoyi
 * @date 2024-07-23
 */
@RestController
@RequestMapping("/system/outlet")
public class SysOutletController extends BaseController
{
    @Autowired
    private ISysOutletService sysOutletService;

    /**
     * 查询网点信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:outlet:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysOutlet sysOutlet)
    {
        startPage();
        List<SysOutlet> list = sysOutletService.selectSysOutletList(sysOutlet);
        return getDataTable(list);
    }

    /**
     * 导出网点信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:outlet:export')")
    @Log(title = "网点信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysOutlet sysOutlet)
    {
        List<SysOutlet> list = sysOutletService.selectSysOutletList(sysOutlet);
        ExcelUtil<SysOutlet> util = new ExcelUtil<SysOutlet>(SysOutlet.class);
        util.exportExcel(response, list, "网点信息管理数据");
    }

    /**
     * 获取网点信息管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:outlet:query')")
    @GetMapping(value = "/{oId}")
    public AjaxResult getInfo(@PathVariable("oId") Long oId)
    {
        return success(sysOutletService.selectSysOutletByOId(oId));
    }

    /**
     * 新增网点信息管理
     */
    @PreAuthorize("@ss.hasPermi('system:outlet:add')")
    @Log(title = "网点信息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysOutlet sysOutlet)
    {
        return toAjax(sysOutletService.insertSysOutlet(sysOutlet));
    }

    /**
     * 修改网点信息管理
     */
    @PreAuthorize("@ss.hasPermi('system:outlet:edit')")
    @Log(title = "网点信息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysOutlet sysOutlet)
    {
        return toAjax(sysOutletService.updateSysOutlet(sysOutlet));
    }

    /**
     * 删除网点信息管理
     */
    @PreAuthorize("@ss.hasPermi('system:outlet:remove')")
    @Log(title = "网点信息管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{oIds}")
    public AjaxResult remove(@PathVariable Long[] oIds)
    {
        return toAjax(sysOutletService.deleteSysOutletByOIds(oIds));
    }
}
